<?php
/* @var $this TurmaController */
/* @var $model Turma */

$this->pageTitle=Yii::app()->name . ' - Turmas';

$this->breadcrumbs=array(
		'Turmas'=>array('index'),
		'Gerenciar Turmas',
);

$this->menu=array(
		array('label'=>'Criar Nova Turma', 'url'=>array('create'),),
);

Yii::app()->clientScript->registerScript('search', "
		$('.search-button').click(function(){
		$('.search-form').toggle();
		return false;
});
		$('.search-form form').submit(function(){
		$('#turma-grid').yiiGridView('update', {
		data: $(this).serialize()
});
		return false;
});
		");
?>

<h2 align="center">Turmas</h2>

<div class="search-form" style="display: none">
	<?php $this->renderPartial('_search',array(
			'model'=>$model,
)); ?>
	<?php $classes = Classe::model()->findAll();
	$list = array();
	foreach($classes as $classe) {
		$list[$classe->nome] = $classe->nome;
	}
	?>
</div>
<?php $this->widget('zii.widgets.grid.CGridView',array(
		'id'=>'turma-grid',
		'pager' => array('cssFile' => Yii::app()->baseUrl . '/css/gridview.css',
				'firstPageLabel'=>'Início',
				'lastPageLabel'=>'Fim',
				'nextPageLabel'=>'Próximo >',
				'header'=>'Página Atual:',
				'prevPageLabel'=>'< Anterior',
				'maxButtonCount'=>'15',),
		'cssFile' => Yii::app()->baseUrl . '/css/gridview.css',
		'htmlOptions'=>array('class'=>'grid-view rounded'),
		'summaryText' => 'Mostrando {start}-{end} de {count} registro(s).',
		'dataProvider'=>$model->search(Yii::app()->session['polo_id'], Yii::app()->session['user_id']),
		'columns'=>array(
				'nome',
				array('name'=>'search_classe',
						'value' => '$data->classe->nome',
						'filter' => $list),
				
				'ano',
				array(
						'name'=> 'search_responsavel',
						'value'=>'$data->responsavel == null ? "" : $data->responsavel->pessoa->nome',
				),
				array(
						'header' => 'Ações',
						'class' => 'CButtonColumn',
						'htmlOptions' =>array('width'=>'40px', 'float'=>'center'),
						'viewButtonImageUrl' => Yii::app()->baseUrl . '/css/' . 'gr-view.png',
						'template' => '{view}',
				),
		),
		'emptyText' => 'Nenhuma Turma cadastrada',
)); ?>

